package com.design.structure.composite.atguigu;

import java.util.ArrayList;
import java.util.List;

/**
 * @ProjectName: design
 * @Package: com.design.structure.composite.atguigu
 * @ClassName: University
 * @Author: shenaiguo
 * @Description:
 * @Date: 2020/9/7 0007 22:52
 */
//  步骤2
//University 就是 Composite ,  可以管理 College
public class University extends OrganizationComponent {
    List<OrganizationComponent> organizationComponents = new ArrayList<OrganizationComponent>();

    // 构造器
    public University(String name, String des) {
        super(name, des);
    }

    // 重 写 add @Override
    protected void add(OrganizationComponent organizationComponent) {
        organizationComponents.add(organizationComponent);
    }

    // 重 写 remove @Override
    protected void remove(OrganizationComponent organizationComponent) {
        organizationComponents.remove(organizationComponent);
    }

    @Override
    public String getName() {

        return super.getName();
    }

    @Override
    public String getDes() {
        return super.getDes();
    }

    @Override
    protected void print() {
        System.out.println("--------------" + getName() + "--------------");
//遍历 organizationComponents
        for (OrganizationComponent organizationComponent : organizationComponents) {
            organizationComponent.print();
        }

    }
}
